local table_name = "wingstage"
local old_table = IMPORT_D:get_table(table_name)
if not old_table then
    return
end

local configs = IMPORT_D:get_table("wingstagestone")
if not configs then
    return
end

local new_table = {}
for _, tbl in pairs(table.copy(configs)) do repeat
    local wingstage = tbl.wingstage
    if not wingstage then
        break
    end

    local config = old_table[wingstage]
    if not config then
        break
    end

    if not tbl.id then
        break
    end

    local id = tbl.id % 1000 - 1
    if id <= 0 then
        break
    end

    tbl.stoneid = id
    tbl.dewreward = tonumber(tbl.dewreward)
    tbl.rewardnum = tonumber(tbl.rewardnum)

    if not new_table[wingstage] then
        new_table[wingstage] = setmetatable({ [id] = tbl }, { __index = config })
    else
        new_table[wingstage][id] = tbl
    end
until true end

IMPORT_D:set(table_name, new_table)
